
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(xg_server)


if(POLICY CMP0074)
  cmake_policy(SET CMP0074 OLD)
endif()

SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/lib)

IF(WIN32)
    IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
        MESSAGE(STATUS "build on windows-msvc: /utf-8")
        SET(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   /utf-8")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
        #add_compile_options(/W4)
        #add_compile_options(/wd4100)
        #关闭性能告警
        ADD_COMPILE_OPTIONS(/wd4800)
#    ELSEIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
#        MESSAGE(STATUS "build on windows-clang-x32: -m32")
#        SET(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -m32")
#        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
    ENDIF()
ENDIF()

# 对可执行文件无效
SET(CMAKE_DEBUG_POSTFIX "_d")

include(import_third_part.cmake)

INCLUDE_DIRECTORIES(
    ${XENV_PYPYTHONCORE_INCLUDE}
    ${XENV_GPERF_INCLUDE}
    ${XENV_LIBUV_INCLUDE}
)

LINK_DIRECTORIES(
    ${XENV_PYPYTHONCORE_LIB}
    ${XENV_GPERF_LIB}
)

SET(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   /utf-8")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")

ADD_SUBDIRECTORY(src)